<?php
$username = $_POST['username'];
$email1 = $_POST['email'];
$email2 = $_POST['confirmemail'];
$password = $_POST['pwd'];


$mysql_host = "mysql16.000webhost.com";
$mysql_database = "a1863493_venture";
$mysql_user = "a1863493_teamven";
$mysql_password = "teamventure1";

if( $email1 != $email2 )
{
	echo "emails don't match";
}
else // connected here V
{
	$link = mysql_connect($mysql_host, $mysql_user, $mysql_password); 
	
	if (!$link) 
	{
		die('Could not connect: ' . mysql_error());
	} 
	echo 'Connected successfully'; 
	mysql_select_db($mysql_database, $link) or die ("Fail");
	
	// Check if username is taken
	$query = sprintf("SELECT name FROM cust_acct WHERE name = '$username'");
	$return = mysql_query($query);

	$result = mysql_result($return,0);

	if( $result)
	{
		echo "username taken";
	} else {
		
	
	$query = sprintf("INSERT INTO cust_acct(name, pass, email) VALUES('$username', '$password', '$email1')"); 

	$result = mysql_query($query); 
	header ('Location: ../index.html');
	}
}




?>